class Solution(object):
    def firstDayBeenInAllRooms(self, nextVisit):
        n = len(nextVisit)
        DP = [0] * n
        base = 10 ** 9 + 7
        for i in range(1, n):
            if nextVisit[i - 1] == i - 1:
                DP[i] = DP[i - 1] + 2
            else:
                DP[i] = (2 * DP[i - 1] - DP[nextVisit[i - 1]] + 2) % base
        return DP[-1]

                

data = Solution()
nextVisit = [0, 0, 2]
print(data.firstDayBeenInAllRooms(nextVisit))